
/**
\file
Definition of the sun::lua::input_lua_interface function.
\author Sean Tromans
*/

#include <sun_pre_compiled.hpp>
#include <sun/lua/input/input.hpp>

#if !defined(SUN_DISABLE_LUA)
#include <sun/lua/lua.hpp>
#endif

#include <sun/input/buttons.hpp>
#include <sun/input/analogues.hpp>

#include <boost/preprocessor.hpp>

#define	SUN_BUTTON_INPUT( e )	luabind::value( BOOST_PP_STRINGIZE( e ), BOOST_PP_CAT( sun::buttons::, e ) ),
#define	SUN_ANALOGUE_INPUT( e )	luabind::value( BOOST_PP_STRINGIZE( e ), BOOST_PP_CAT( sun::analogues::, e ) ),

namespace sun
{

	namespace lua
	{

		namespace detail
		{

			/** Dummy struct to allow exposing free button enums to Lua. */
			struct buttons_namespace
			{
			};

			/** Dummy struct to allow exposing free analogue enums to Lua. */
			struct analogues_namespace
			{
			};

		};

		/**
		Exposes all possibly button and anaologue inputs to lua.
		@param L The lua state being initialsed.
		\author Sean Tromans
		*/
		void input_lua_interface( lua_State * L )
		{
#if !defined(SUN_DISABLE_LUA)

			luabind::module( L, "sun" )
			[
				luabind::class_<detail::buttons_namespace>( "buttons" )
					.enum_( "constants" )
					[
						#include <sun/input/detail/button_declarations.hpp>

						luabind::value( "number_of", sun::buttons::number_of )
					],

				luabind::class_<detail::analogues_namespace>( "analogues" )
					.enum_( "constants" )
					[
						#include <sun/input/detail/analogue_declarations.hpp>

						luabind::value( "number_of", sun::analogues::number_of )
					]
			];
#else
			NMN_UNUSED( L );
#endif
		}

	};

};

#undef	SUN_ANALOGUE_INPUT
#undef	SUN_BUTTON_INPUT
